﻿namespace Skymate
{
    using Abp.Events.Bus;

    using SuperSocket.SocketBase;
    using SuperSocket.SocketBase.Protocol;

    public class LightServer : AppServer<LightAppSession, SemaphoreRequestInfo>
    {
        public LightServer()
            : base(new DefaultReceiveFilterFactory<LightReceiveFilter, SemaphoreRequestInfo>())
        {
        }

        protected override void OnNewSessionConnected(LightAppSession session)
        {
            /*this._mainForm.AddClientForm(
                session,
                session.RemoteEndPoint
                .ToString());*/

            EventBus.Default.Trigger(new SessionConnectedEvent(session.RemoteEndPoint.ToString(), session));

            base.OnNewSessionConnected(session);
        }

        protected override void OnSessionClosed(LightAppSession session, CloseReason reason)
        {
            EventBus.Default.Trigger(new SessionClosedEvent(session.RemoteEndPoint.ToString()));

            base.OnSessionClosed(session, reason);
        }
    }
}